home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / CHAROUT.C < prev    next >
Text File  |  1989-12-30  |  748b  |  23 lines

  1. /*   CHAROUT.C  putc()  fopen()<--append  */
  2. /*   This appends some words to an existing file with  putc. In this example
  3. putc is in a loop so that it's one character at a time action can be used so
  4. as to write a whole line.  */
  5.  
  6. #include "stdio.h"
  7. main()
  8. {
  9. FILE *point;
  10. char others[35];
  11. int indexer,count;
  12.  
  13.    strcpy(others,"Additional lines.");
  14.    point = fopen("tenlines.txt","a"); /* open for appending */
  15.  
  16.    for (count = 1;count <= 10;count++) {
  17.       for (indexer = 0;others[indexer];indexer++)
  18.          putc(others[indexer],point);  /* output a single character */
  19.       putc('\n',point);                /* output a linefeed */
  20.    }
  21.    fclose(point);
  22. }
  23.